﻿using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using Inaction.Core;
using Inaction.Mapping;
#if WPF
using System.Windows.Controls;
#else
using System.Drawing;
#endif

namespace Inaction.Business.Security.Abstract
{
    [Table("MenuInfo"), DisplayName("菜单"), Serializable]
    public abstract class MenuInfo<T> : Inaction.Business.Entity<T> where T : MenuInfo<T>, new()
    {
        #region 属性

        public static readonly Property<Guid?> IdProperty = RegisteProperty<Guid?>(p => p.Id);
        Guid? _id;
        [Column("Id"), DisplayName("菜单"), Display(Description = "菜单")]
        public Guid? Id
        {
            get { return _id; }
            internal set { SetProperty(IdProperty, ref _id, value); }
        }

        public static readonly Property<AppType?> AppTypeProperty = RegisteProperty<AppType?>(p => p.AppType,
#if WINDOWS
            Inaction.AppType.WinForm
#elif WPF
            Inaction.AppType.WPF
#elif WEB
            Inaction.AppType.Web
#endif
);
        AppType? _appType;
        [Column("AppType"), DisplayName("应用类型"), Display(Description = "应用类型")]
        public AppType? AppType
        {
            get { return _appType; }
            set { SetProperty(AppTypeProperty, ref _appType, value); }
        }

        public static readonly Property<String> NameProperty = RegisteProperty<String>(p => p.Name);
        String _name;
        [Column("Name"), DisplayName("名称"), Display(Description = "名称")]
        public String Name
        {
            get { return _name; }
            set { SetProperty(NameProperty, ref _name, value); }
        }

        public static readonly Property<String> CodeProperty = RegisteProperty<String>(p => p.Code);
        String _code;
        [Column("Code"), DisplayName("代码"), Display(Description = "代码")]
        public String Code
        {
            get { return _code; }
            set { SetProperty(CodeProperty, ref _code, value); }
        }

        public static readonly Property<Int32?> OrderNoProperty = RegisteProperty<Int32?>(p => p.OrderNo, 99);
        Int32? _orderNo;
        [Column("OrderNo"), DisplayName("序号"), Display(Description = "序号")]
        public Int32? OrderNo
        {
            get { return _orderNo; }
            set { SetProperty(OrderNoProperty, ref _orderNo, value); }
        }

        public static readonly Property<Image> ImageProperty = RegisteProperty<Image>(p => p.Image);
        Image _image;
        [Column("Image"), DisplayName("菜单图片"), Display(Description = "菜单图片")]
        public Image Image
        {
            get { return _image; }
            set { SetProperty(ImageProperty, ref _image, value); }
        }

        public static readonly Property<Guid?> ParentIdProperty = RegisteProperty<Guid?>(p => p.ParentId);
        Guid? _parentId;
        [Column("ParentId"), DisplayName("上级菜单"), Display(Description = "上级菜单")]
        public Guid? ParentId
        {
            get { return _parentId; }
            set { SetProperty(ParentIdProperty, ref _parentId, value); }
        }

        public static readonly Property<Boolean?> SpliterProperty = RegisteProperty<Boolean?>(p => p.Spliter);
        Boolean? _spliter;
        [Column("Spliter"), DisplayName("启用分隔符"), Display(Description = "启用分隔符")]
        public Boolean? Spliter
        {
            get { return _spliter; }
            set { SetProperty(SpliterProperty, ref _spliter, value); }
        }

        public static readonly Property<String> TargetObjProperty = RegisteProperty<String>(p => p.TargetObj);
        String _targetObj;
        [Column("TargetObj"), DisplayName("目标对象"), Display(Description = "目标对象")]
        public String TargetObj
        {
            get { return _targetObj; }
            set { SetProperty(TargetObjProperty, ref _targetObj, value); }
        }

        public static readonly Property<String> ParameterProperty = RegisteProperty<String>(p => p.Parameter);
        String _parameter;
        [Column("Parameter"), DisplayName("参数"), Display(Description = "参数")]
        public String Parameter
        {
            get { return _parameter; }
            set { SetProperty(ParameterProperty, ref _parameter, value); }
        }

        public static readonly Property<String> RemarkProperty = RegisteProperty<String>(p => p.Remark);
        String _remark;
        [Column("Remark"), DisplayName("备注"), Display(Description = "备注")]
        public String Remark
        {
            get { return _remark; }
            set { SetProperty(RemarkProperty, ref _remark, value); }
        }


        public static readonly Property<String> CreaterProperty = RegisteProperty<String>(p => p.Creater);
        String _creater;
        [Column("Creater"), DisplayName("创建人"), Display(Description = "创建人"), Browsable(false)]
        public String Creater
        {
            get { return _creater; }
        }

        public static readonly Property<DateTime?> CreateTimeProperty = RegisteProperty<DateTime?>(p => p.CreateTime);
        DateTime? _createTime;
        [Column("CreateTime"), DisplayName("创建时间"), Display(Description = "创建时间"), Browsable(false)]
        public DateTime? CreateTime
        {
            get { return _createTime; }
        }

        public static readonly Property<String> UpdaterProperty = RegisteProperty<String>(p => p.Updater);
        String _updater;
        [Column("Updater"), DisplayName("修改人"), Display(Description = "修改人"), Browsable(false)]
        public String Updater
        {
            get { return _updater; }
        }

        public static readonly Property<DateTime?> UpdateTimeProperty = RegisteProperty<DateTime?>(p => p.UpdateTime);
        DateTime? _updateTime;
        [Column("UpdateTime"), DisplayName("修改时间"), Display(Description = "修改时间"), Browsable(false)]
        public DateTime? UpdateTime
        {
            get { return _updateTime; }
        }

        #endregion
    }
}
